<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      .box {
        width: 200px;
        height: 400px;
        background-color: cyan;
        display: none;
        position: relative;
        left: 0px;
        top: 0px;
      }
      li {
        list-style: none;
        /* position: absolute; */
        height: 100px;
        border: 1px solid;
        display: block;
        box-sizing: border-box;
        text-align: center;
        line-height: 100px;
        font-size: 50px;
      }
    </style>
  </head>
  <body>
    <!-- <div class="box"></div> -->
    <ul class="box">
      <li>菜单1</li>
      <li>菜单2</li>
      <li>菜单3</li>
      <li>菜单4</li>
    </ul>
    <script>
      var menu = document.querySelector(".box");
      document.oncontextmenu = function (e) {
        // console.log(111);
        e.preventDefault();
        console.log(e.clientX, e.clientY);
        menu.style.display = "block";
        menu.style.left = e.clientX + "px";
        menu.style.top = e.clientY + "px";
      };
    </script>
  </body>
</html>
